<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateTaskExec extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('task_exec', function (Blueprint $table) {
            $table->integerIncrements('id');
            $table->unsignedInteger('user_id');
            $table->unsignedInteger('cooperative_id')->default(0)->comment('合作商id');
            $table->unsignedInteger('employer_id')->default(0)->comment('悬赏主id（发布任务的用户ID）');
            $table->unsignedInteger('task_id')->default(0)->comment('任务ID');
            $table->unsignedInteger('getter_time')->default(0)->comment('领取任务的时间');
            $table->unsignedInteger('remaining_time')->default(0)->comment('剩余完成任务时间');
            $table->unsignedTinyInteger('audit_status')->default(0)->comment('提交任务审核状态：1待审核，2通过，3失败');
            $table->unsignedTinyInteger('arbitration_status')->default(0)->comment('仲裁状态：1待审核，2已审核');
            $table->unsignedTinyInteger('finish_status')->default(0)->comment('结束状态：1未结束，2结束（结束：审核通过；超时未提交；审核失败且48小时未操作；仲裁审核完成）');
            $table->unsignedTinyInteger('status')->default(0)->comment('领取任务状态：1待提交，2已提交，3申请仲裁');
            $table->string('gather_user_info', 255)->default('')->comment('收集用户信息');
            $table->text('audit_content')->nullable()->comment('提交内容（任务截图）');
            $table->text('audit_fail_context')->nullable()->comment('审核失败描述');
            $table->unsignedTinyInteger('audit_fail_number')->default(0)->comment('提交失败次数，最大5次');
            $table->unsignedInteger('audit_fail_time')->default(0)->comment('审核失败时间');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('task_exec');
    }
}
